home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer 2.0 / Internet Surfer 2.0 (Wayzata Technology) (1996).iso / pc / text / mac / faqs.378 < prev    next >
Text File  |  1996-02-12  |  28KB  |  727 lines

  1. Frequently Asked Questions (FAQS);faqs.378
  2.  
  3.  
  4.  
  5. For Motif 1.1.1, 1.1.2 and 1.1.3 you will need to compile Xlib and Xt with a
  6. MOTIF_BC flag set to YES (page 8, section 3.3 of the R5 release notes), or
  7. you'll also have a link problem (LowerCase) and a fatal run time problem
  8. (XContext manager).  If your applications come up with "Unknown keysym name:
  9. osfActivate" errors, check the variable ProjectRoot. The name
  10. /$PROJECTROOT/lib/XKeysymDB will have been wired into your Xlib.
  11.  
  12. In Motif 1.1.0, XtCallCallback uses NULL as the first argument instead of a
  13. widget ID. This was ok under R4, but must be changed in the source for R5. It
  14. was changed by OSF from Motif 1.1.1 onward.
  15.  
  16. Mrm won't work at all (can't link since it uses an X private variable that has
  17. disappeared in R5).  Thre is an MIT patch that may fix this??  [I confess
  18. ignorance of Mrm and UIL].
  19.  
  20. -----------------------------------------------------------------------------
  21. Subject: 18)  How can I find which version of Motif I have?
  22.  
  23. Answer: The macro XmVERSION gives you the version number.  The macro
  24. XmREVISION gives you the major revision number.  The macro XmVersion combines
  25. these e.g. a value of 1002 is Motif 1.2.
  26.  
  27. To find the minor revision number is not easy.  From Motif 1.1.3 onwards, try
  28. this:
  29.  
  30.    'strings `which mwm` | grep OSF'.
  31.  
  32. to get the full version number e.g. 1.1.3.
  33.  
  34.  
  35. -----------------------------------------------------------------------------
  36. Subject: 19) TOPIC: LITERATURE
  37.  
  38. -----------------------------------------------------------------------------
  39. Subject: 20)  What books should I read or do I need to program using Motif?
  40.  
  41. [Last modified: November 92]
  42.  
  43. Answer: Ken Lee of the DEC Western Software Laboratory (klee@wsl.dec.com)
  44. regularly posts to comp.windows.x and ba.windows.x a list of reference books
  45. and articles on X and X programming.  In FAQ comp.windows.x an extract of his
  46. list appears. Specifically for Motif programming, though:
  47.  
  48. OSF/Motif Programmers Guide, Prentice-Hall 13-640525-8 (Motif 1.0) ISBN 0-13-
  49. 640681-5 (Motif 1.1) (NB: This makes use of the demo programs that you get
  50. with a Motif source license.  The programs are not included and may or may not
  51. be available on your system.)
  52.  
  53. OSF/Motif Programmers Reference Manual, Prentice-Hall 13-640517-17 (Motif 1.0)
  54.  ISBN 0-13-640616-5 (Motif 1.1) You will need this for the system calls.
  55.  
  56. OSF/Motif Style Guide, Prentice-Hall 13-640491-X (Motif 1.0) ISBN 0-13-
  57. 640673-4 (Motif 1.1) You will need this to get some idea of how to write
  58. programs with the correct `look and feel'.
  59.  
  60. You should read at least one of the the non-OSF books on Motif:
  61.  
  62. Young, Doug. "The X Window System: Applications and Programming with Xt (Motif
  63. Version)," Prentice Hall, 1989 (ISBN 0-13-497074-8). The excellent tutorial "X
  64. Window Systems Programming and Applications with Xt," (ISBN 0-13-972167-3)
  65. updated for Motif. [The examples from the Motif version are available on
  66. export in ~ftp/contrib/young.motif.tar.Z]
  67.  
  68. Marshall Brain at brain@adm.csc.ncsu.edu posted a set of simple and useful
  69. Motif tutorials.
  70.  
  71. Berlage, Thomas Berlage, OSF/Motif: Concepts and Programming, Addison-Wesley,
  72. UK, 1991. ISBN 0-201-55792-4.
  73.  
  74. Johnson, Eric F. and Kevin Reichard, Power Programming Motif, MIS: Press,
  75. Portland, OR, 1991. ISBN 1-55828-059-6. Book with disk, ISBN 1-55828-061-8.
  76.  
  77. Heller, Dan, The Motif Programming Manual, Volume 6 of the O'Reilly series on
  78. X.  This is the most complete volume on Motif programming available.  ISBN 0-
  79. 937175-70-6.
  80.  
  81. Barkakati, Nabajyoti, W Window System Programming, SAMS. ISBN 0-672-22750-9.
  82. This contains a section on Motif.
  83.  
  84. Newmarch, Jan, The X Window System and Motif - A Fast Track Approach.
  85. Addison-Wesley, ISBN 0-201-53931-4.
  86.  
  87. You will also need books and references on Xt such as:
  88.  
  89. Asente, Paul J., and Swick, Ralph R., "X Window System Toolkit, The Complete
  90. Programmer's Guide and Specification", Digital Press, 1990.  The bible on Xt.
  91. A treasury of information, excellent and invaluable.  Distributed by Digital
  92. Press, ISBN 1-55558-051-3, order number EY-E757E-DP; and by Prentice- Hall,
  93. ISBN 0-13-972191-6.
  94.  
  95. Nye, Adrian, and Tim O'Reilly, "X Toolkit Programming Manual, Volume 4,"
  96. O'Reilly and Associates, 1989. The folks at O'Reilly give their comprehensive
  97. treatment to programming with the MIT Intrinsics; R4 versions are now
  98. available, as is a Motif 1.1 version (Volume 4M).
  99.  
  100.  
  101. Flanagan, David, ed.,  "X Toolkit Reference Manual, Volume 5," O'Reilly and
  102. Associates, 1992a, Third Edition. A professional reference manual for the MIT
  103. X11R4 and X11R5 Xt.
  104.  
  105. Books and reference manuals on Xlib may also be useful.
  106.  
  107.  
  108.  
  109. -----------------------------------------------------------------------------
  110. Subject: 21) TOPIC: MWM
  111.  
  112. -----------------------------------------------------------------------------
  113. Subject: 22) What is the difference between Motif and mwm?
  114.  
  115. Answer: mwm is a window manager. Motif itself is made up of four parts: a
  116. User-Interface Guideline, an API toolkit of `C' routines which helps in the
  117. building of applications which conform to the Guideline, the window manager
  118. mwm, and a language UIL which is designed to ease user interface development.
  119. In general mwm will run an application built with any X-windows API, and in
  120. general an application built using the Motif toolkit will run under any window
  121. manager.
  122.  
  123.  
  124. -----------------------------------------------------------------------------
  125. Subject: 23) Does anyone have an alternative set of 3-D defaults for a
  126. monochrome screen?
  127.  
  128. Answer: This is obviously a matter of taste. Some alternatives suggested
  129. include
  130.  
  131. !Benjamin Schreiber, bs@osf.osf.org, bs@cs.brandeis.edu
  132. Mwm*foreground:                 black           ! Actually, when a window is
  133. Mwm*background:                 white           ! deactivated, the background
  134. Mwm*backgroundPixmap:           50_foreground   ! becomes white, insted of
  135. Mwm*topShadowPixmap:            white           ! 50% foreground (grey)
  136.  
  137. Mwm*activeForeground:           black
  138. Mwm*activeBackground:           white
  139. Mwm*activeBackgroundPixmap:     50_foreground
  140. Mwm*activeTopShadowPixmap:      white
  141.  
  142. Mwm*menu*backgroundPixmap:      background
  143. Mwm*menu*topShadowPixmap:       50_foreground
  144.  
  145. Mwm*title*foreground:                   black
  146. Mwm*title*background:                   white
  147. Mwm*title*backgroundPixmap:             white
  148. Mwm*title*topShadowPixmap:              50_foreground
  149. Mwm*title*activeForeground:             white
  150. Mwm*title*activeBackground:             black
  151. Mwm*title*activeBackgroundPixmap:       black
  152. Mwm*title*activeBottomShadowPixmap:     50_foreground
  153.  
  154. Mwm*feedback*backgroundPixmap:          white
  155.  
  156. or
  157.  
  158. ! From: tsang@isi.com (Kam C. Tsang)
  159. Mwm*background:                      White
  160. Mwm*activeBackground:                White
  161. Mwm*activeBackgroundPixmap:          25_foreground
  162. Mwm*foreground:                      Black
  163. Mwm*activeForeground:                Black
  164. Mwm*menu*background:                 white
  165. Mwm*menu*foreground:                 black
  166. xterm*Foreground:                    black
  167. xterm*Background:                    white
  168.  
  169.  
  170. or
  171.  
  172. ! From: ucsd.edu!usc!snorkelwacker!paperboy!yee  (Michael K. Yee)
  173. Mwm*cleanText:                          True
  174.  
  175. Mwm*activeBackground:           white
  176. Mwm*activeForeground:           black
  177. Mwm*background:                 white
  178. Mwm*foreground:                 black
  179.  
  180. Mwm*client*activeBackgroundPixmap:      50_foreground
  181. Mwm*client*activeTopShadowPixmap:       foreground
  182. Mwm*client*activeBottomShadowPixmap:    background
  183.  
  184. !Mwm*client*background:                 white
  185. !Mwm*client*foreground:                 black
  186. Mwm*client*backgroundPixmap:            75_foreground
  187. Mwm*client*topShadowPixmap:             foreground
  188. Mwm*client*bottomShadowPixmap:          background
  189.  
  190. !Mwm*feedback*background:               white
  191. !Mwm*feedback*foreground:               black
  192. Mwm*feedback*backgroundPixmap:          50_foreground
  193. !Mwm*feedback*topShadowPixmap:          25_foreground
  194. !Mwm*feedback*bottomShadowPixmap:       background
  195.  
  196. !Mwm*menu*background:                   white
  197. !Mwm*menu*foreground:                   black
  198. Mwm*menu*backgroundPixmap:              foreground
  199. !Mwm*menu*topShadowPixmap:              foreground
  200. !Mwm*menu*bottomShadowPixmap:           background
  201.  
  202. !Mwm*icon*background:                   white
  203. !Mwm*icon*foreground:                   black
  204. Mwm*icon*activeBackgroundPixmap:        50_foreground
  205. Mwm*icon*activeBottomShadowPixmap:      foreground
  206. Mwm*icon*backgroundPixmap:              75_foreground
  207.  
  208.  
  209.  
  210. -----------------------------------------------------------------------------
  211. Subject: 24)  How can I modify the Motif window manager decorations?
  212.  
  213. Answer: In resource files, use the window manager's client resource (which is
  214. the application) and the resource clientDecoration:
  215.  
  216. Mwm*XClock.clientDecoration:   none
  217.  
  218. turns off all clock decorations.  See the mwm(1) entry for other
  219. possibilities.
  220.  
  221. Programmatically, set the VendorShell resource XmNmwmDecorations to
  222. appropriate values: MWM_DECOR_NONE (or a bitwise or of values).
  223.  
  224. -----------------------------------------------------------------------------
  225. Subject: 25)  How can I turn off the Motif window manager functions from the
  226. system menu?
  227. [Last modified: October 92]
  228.  
  229. Answer: The user of an application can control functions in the system menu
  230. for an application using the mwm resource clientFunctions:
  231.  
  232.         mwm.application_name.clientFunctions: -resize -close
  233.  
  234. Note that mwm will have to be restarted after putting this in their resource
  235. database.
  236.  
  237.  
  238. Answer: The writer of an application can only remove items.  Be warned that
  239. your users will probably gnash their teeth, swear furiously at your product
  240. and stop using it if they discover that you have done this.  (Especially if
  241. you have removed the Close button, your application has hung and it has taken
  242. up all of memory and swap so it can't be killed.) Much better is to catch the
  243. action gracefully as in the next question.
  244.  
  245.         #include <Xm/MwmUtil.h>
  246.  
  247.         XtVaGetValues(shell, XmNmwmFunctions, &int_val, NULL);
  248.         int_val &= ~(MWM_FUNC_CLOSE | MWM_FUNC_ALL);
  249.         XtVaSetValues(shell, XmNmwmFunctions, int_val, NULL);
  250.  
  251.  
  252.  
  253. -----------------------------------------------------------------------------
  254. Subject: 26)  How can tell I if the user has selected the "Close" item on the
  255. system menu attached to the top-level shell?  I need to do some clean up
  256. before exiting.
  257.  
  258. Answer:          This works with R4 Intrinsics
  259.  
  260.         void FinalCleanupCB(w, client_data, call_data)
  261.         Widget   w;
  262.         caddr_t  client_data, call_data;
  263.         {
  264.                 /* tidy up stuff here */
  265.                 ...
  266.                 /* exit if you want to */
  267.                 exit (0);
  268.         }
  269.  
  270.         main()
  271.         {
  272.                 Atom wm_delete_window;
  273.  
  274.                 ...
  275.                 XtRealizeWidget(toplevel);
  276.                 ...
  277.                 wm_delete_window =
  278.                         XmInternAtom(XtDisplay(toplevel),
  279.                                 "WM_DELETE_WINDOW", False);
  280.                 XmAddWMProtocolCallback(toplevel, wm_delete_window,
  281.                         FinalCleanupCB, NULL);
  282.                 XtMainLoop();
  283.         }
  284.  
  285. This will still kill the application.  To turn this behaviour off so that the
  286. application is not killed, set the shell resource XmNdeleteResponse to
  287. XmDO_NOTHING.  This means that users cannot kill your application via the
  288. system menu, and may be a bad thing.
  289.  
  290. If you are running R3, Bob Hays (bobhays@spss.com) has suggested this:
  291. "Trapping on the delete window atom does not work as I cannot force my action
  292. routine to the top of the action list for the activity desired, so the window
  293. manager kills my window anyway BEFORE I can do anything about it.  And, to
  294. make matters worse, the window manager (Motif in this case) tacks its atoms
  295. and handlers onto the window at some unknown point down the line after the
  296. creation of the shell widget as far as I can tell.  So....
  297.  
  298. I have a procedure as an action routine for ClientMessage.  Then, if I get a
  299. property change event on the window manager protocols, I then tack on
  300. WM_SAVE_YOURSELF.  If I get this request, I clean up (it seems to happen on
  301. WM_DELETE_WINDOW, BTW, if you remove WM_DELETE_WINDOW from the WM protocols
  302. atom) and exit.  Works great and is less filling overall:-)."
  303.  
  304.  
  305. -----------------------------------------------------------------------------
  306. Subject: 27)  Is there an mwm virtual desktop manager?
  307.  
  308. Answer: Peter E. Wagner (pew@cs.brown.edu): Imagine that your "desktop"
  309. extends beyond the view provided by your monitor.  A virtual window manager
  310. gives you access to the space beyond your viewport (i.e. your screen) by
  311. allowing you to move the viewport to other areas of the extended desktop.
  312.  
  313. The first one is Solbourne's swm, which spawned vtwm/tvtwm/olvwm.
  314.  
  315. David B. Lewis created one.  suresh@unipalm.co.uk has further developed it
  316. into the UniPalm product DOORS, which is only available as a source code
  317. extension to the MOTIF window manager.  The price of the source and unlimited
  318. right to distribute binaries is 10,000 pounds Sterling.  Alternately, source
  319. and right to use within one company is 2,000 pounds Sterling.  Contact Peter
  320. Dawe
  321.  
  322. Unipalm Limited                         Voice: +44 (0) 223 420002
  323. 216 The Science Park                    Fax:   +44 (0) 223 426868
  324. CAMBRIDGE
  325. CB4 4WA
  326.  
  327.  
  328.  
  329. An enhancement request for such an object has been filed with OSF.
  330.  
  331. -----------------------------------------------------------------------------
  332. END OF PART ONE
  333. --
  334. +----------------------+---+
  335.   Jan Newmarch, Information Science and Engineering,
  336.   University of Canberra, PO Box 1, Belconnen, Act 2616
  337.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  338. Xref: bloom-picayune.mit.edu comp.windows.x.motif:13658 news.answers:4509
  339. Newsgroups: comp.windows.x.motif,news.answers
  340. Path: bloom-picayune.mit.edu!enterpoop.mit.edu!news.media.mit.edu!micro-heart-of-gold.mit.edu!wupost!uunet!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!news
  341. From: jan@ise.canberra.edu.au (Jan Newmarch)
  342. Subject: Motif FAQ (Part 2 of 5)
  343. Message-ID: <1992Dec10.001605.10450@csc.canberra.edu.au>
  344. Followup-To: comp.windows.x.motif
  345. Keywords: FAQ question answer
  346. Sender: news@csc.canberra.edu.au
  347. Reply-To: jan@ise.canberra.edu.au (Jan Newmarch)
  348. Organization: University of Canberra
  349. Date: Thu, 10 Dec 92 00:16:05 GMT
  350. Approved: news-answers-request@MIT.Edu
  351. Expires: +1 months
  352. Lines: 764
  353.  
  354. Archive-name: motif-faq/part2
  355. Last-modified: Thu December 12 1992
  356. Version: 2.12
  357.  
  358.  
  359.  
  360. -----------------------------------------------------------------------------
  361. Subject: 28) TOPIC: MOTIF GENERATORS
  362.  
  363. -----------------------------------------------------------------------------
  364. Subject: 29)*  What prototyping tools are there to generate Motif code?
  365. [Last modified: November 92]
  366.  
  367. Answer: [An FAQ is for "personal opinions" on these tools.  I don't think it
  368. is appropriate to give such opinions through this particular posting, so I
  369. haven't included any.]
  370.  
  371. `Prototyping tools' come in two forms: those that can be used to design the
  372. interface only (GUI builder), and those that go beyond this to give support
  373. for application code (User Interface Management Systems).  There are a number
  374. of commercial and non-commercial tools of both kinds that will support the
  375. Motif interface.  They include:
  376.  
  377. GUI builders:
  378.  
  379. Builder Xcessory
  380. X Build
  381. ExoCODE/xm
  382.  
  383.  
  384. UIMS:
  385.  
  386. WINTERP
  387. ALEX
  388. Widget Creation Library
  389. UIMX
  390. Serpent
  391. TeleUse
  392. X-Designer
  393. XFaceMaker2
  394. MOTIFATION
  395. MetaCard
  396.  
  397.  
  398. Some contact addresses are:
  399.  
  400. WINTERP: You may obtain the current source, documentation, and examples via
  401. anonymous ftp from host export.lcs.mit.edu: in directory contrib/winterp you
  402. will find the compress(1)'d tar(1) file winterp.tar.Z. If you do not have
  403. Internet access you may request the source code to be mailed to you by sending
  404. a message to winterp-source%hplnpm@hplabs.hp.com or hplabs!hplnpm!winterp-
  405. source.
  406.  
  407. Serpent: The S/W is free (anonymous ftp) from ftp.sei.cmu.edu.  For more info
  408. contact erik/robert at serpent-info@sei.cmu.edu.
  409.  
  410. TeleUse: In the U.K., send mail to xtech@unipalm.co.uk or call +44 954 211862.
  411. In the US contact Telesoft at:
  412.  
  413. TeleSoft, 5959 Cornerstone Court West, San Diego, CA 92121-9891
  414.              Phone: +1 619-457-2700
  415.                     +1 619-452-1334 Fax
  416.              Email: guisales@telesoft.com (Sales),
  417.                     guisupport@telesoft.com (Customer Support)
  418.  
  419.  
  420. Builder Xcessory from ICS.  More details are available by sending a request to
  421. info@ics.com.  Address: ICS Inc., 201 Broadway, Cambridge MA 02139, Tel. (617)
  422. 621-0060, Fax. (617) 621-9555
  423.  
  424. X-Designer: From Imperial Software Technology in the UK.  Email address is
  425. sales@ist.co.uk.  (+44) 743 587055
  426.  
  427. Recently, V.I. Corporation have become the distributor for the X-Designer
  428. product in the United States.  In addition, IST and V.I. Corporation have
  429. developed a product called DVX-Designer that merges X-Designer with their GUI
  430. product called DataViews.  Other merged products are in the works.  For more
  431. information, people can contact:
  432.  
  433.         V.I. Corporation
  434.         47 Pleasant Street
  435.         Northampton, MA  01060
  436.         Phone: (413) 586-4144
  437.         Fax: (413) 586-3805
  438.         Email: vi@vicorp.com
  439.  
  440.  
  441. ExoCODE/xm: From Expert Object Corp., 7250 Cicero Avenue, Lincolnwood, IL
  442. 60646 (708)676-5555.
  443.  
  444. X Build: From Nixdorf Computer (Waltham, MA) xbuild@nixdorf.com
  445.  
  446.  
  447. ExoCode: From EXOC (Chicago, IL)
  448.  
  449. UIMX: Visual Edge Software Limited, 3870 Cote Vertu, St Laurent, Quebec, H4R
  450. 1V4, Phone: (514) 332-6430, Fax:   (514) 332-5914, or: Visual Edge Software
  451. Ltd., 101 First Street, Suite 443, Los Altos, CA 94022, Phone: (415) 948-0753,
  452. Fax:   (415) 948-0843
  453.  
  454. The Widget Creation Library: The distribution is available in several ways.
  455. The preferred approach it for you to get the compressed tar file using
  456. anonymous ftp from:
  457.  
  458.     export.lcs.mit.edu    (18.30.0.238) /contrib/Wcl.1.06.tar.Z
  459.  
  460.  
  461. XFaceMaker2: NSL -  Non Standard Logics S.A., 57-59, rue Lhomond, 75005  Paris
  462. - France, Phone: +33 (1) 43.36.77.50, Fax:   +33 (1) 43.36.59.78 email:
  463. requests@nsl.fr or requests%nsl.fr@inria.fr for information.
  464.  
  465. Their North American office: Non Standard Logics, Inc., 4141 State Street,
  466. Suite B-11, Santa Barbara CA 93110, Tel: 805 964 9599, Fax: 805 964 4367
  467.  
  468.  
  469. MOTIFATION: AKA EDV, Universitaetsstrasse 125, 4630 Bochum, Germany, Tel: +49
  470. (0) 234 / 33397-0, Fax: +49 (0) 234 / 33397-40
  471.  
  472.  
  473. ALEX: For more information contact Michael Karliner on (+44) 81 566 2307 or
  474. E-mail to alex@s-strat.co.uk.  ALEX Technologies, Waterman's Yard, 32a The
  475. Mall, Ealing, London W5, UK.
  476.  
  477. MetaCard: MetaCard 1.0 is supported on five popular UNIX/X11 platforms: SPARC,
  478. Sun3, DECstation, HP-9000/300, and SCO ODT.  An HP-9000/700 port is underway
  479. and should be available by the end of July.  [They] plan to support IBM
  480. RS/6000, SGI Iris, and DG AViiON sometime fall '92.  For more information, or
  481. to receive a free save-disabled but licensable copy of MetaCard, email to
  482. info@metacard.com or call 303- 447-3936.  If you have anonymous FTP access to
  483. the Internet, you can download the current engines, documentation, and an
  484. unlicensed Home stack from ftp.metacard.com (128.138.213.21), directory
  485. MetaCard.  Commercial users can get MetaCard from world.std.com
  486. (192.74.137.5), directory pub/Metacard.  If you don't have an anonymous ftp
  487. access, you can also download MetaCard from The World using kermit or xmodem
  488. from the ~ftp/pub/MetaCard directory.  Sign up by calling 617-739-0202 (voice)
  489. or via modem by dialing 617-739-9753 (7 bits even parity) and logging in as
  490. new.
  491.  
  492. MetaCard 1.2 Beta 5 is now available for anonymous FTP from ftp.metacard.com
  493. (directory MetaCard/1.2B5), and ftp.uu.net (directory vendor/MetaCard/1.2B5).
  494.  
  495.  
  496. -----------------------------------------------------------------------------
  497. Subject: 30) TOPIC: TEXT WIDGET
  498.  
  499. -----------------------------------------------------------------------------
  500. Subject: 31) Why does  pressing  <return> in a text widget do nothing?  This
  501. happens using Motif 1.0 when I have a text widget inside a bulletin board (or
  502. form) inside a dialog shell. (In Motif 1.1 it is fixed for both text and list
  503. widgets.)
  504.  
  505. Answer: In single line mode, pressing the <return> key usually invokes the
  506. activate() action, and in multi-line mode, the newline() action.  However,
  507. whenever a widget is the child of a bulletin board widget which is the child
  508. of a dialog shell, the bulletin board forces all of its children to translate
  509. <return> to the bulletin board action Return() which is usually associated
  510. with the default button of the dialog.  To restore the text actions of
  511. activate() or newline(), you need to overide the Return() action of the
  512. bulletin board.
  513.  
  514.  
  515.         /* declarations */
  516.         /* for a single line widget */
  517.         char newTrans[] = "<Key>Return : activate()";
  518.         /* for a multi line widget */
  519.         char newTrans[] = "<Key>Return : newline()";
  520.         XtTranslations transTable;
  521.  
  522.         /* in executable section */
  523.  
  524.         transTable = XtParseTranslationTable(newTrans);
  525.  
  526.         /* after creating but before managing text widget */
  527.  
  528.         XtOverrideTranslations(textWidget, transTable);
  529.  
  530.  
  531. -----------------------------------------------------------------------------
  532. Subject: 32) When I add text to a scrolling text widget how can I get the new
  533. text to show?
  534.  
  535. Answer: Use the call undocumented in Motif 1.0
  536.  
  537.         void XmTextShowPosition(w, position)
  538.         Widget w;
  539.         XmTextPosition position;
  540.  
  541. where the position is the number of characters from the beginning of the
  542. buffer of the text to be displayed. If you don't know how many characters are
  543. in the buffer, use another call undocumented in Motif 1.0
  544.  
  545.         position = XmTextGetLastPosition(w)
  546.  
  547.  
  548. -----------------------------------------------------------------------------
  549. Subject: 33)* Does the text widget support 16 bit character fonts?
  550.  
  551.  
  552. [Last modified: November 92]
  553.  
  554. Answer: R5 has support for 16 bit character sets, and Motif 1.2 uses that.
  555. Neither Motif 1.0 nor 1.1 support 16 bit sets.
  556.  
  557. -----------------------------------------------------------------------------
  558. Subject: 34) How can I stop the text widget from echoing characters typed?  I
  559. need to turn off echo for password input.
  560.  
  561. Answer: Use the modifyVerifyCallback to tell when input is received. Set the
  562. `doit' field in the XmTextVerifyCallbackStruct to False to stop the echo. In
  563. Motif 1.0 this will cause a beep per character: Live with it, because at 1.1
  564. you can turn it off.  Note that password hiding is inherently insecure in X -
  565. someone may have an X grab on the keyboard and be reading all characters typed
  566. in anyway.
  567.  
  568. Another solution often proposed is to set the foreground and background
  569. colours to be the same, effectively hiding the text.  This has a major flaw:
  570. someone may select the text (triple click the mouse to get the line), and then
  571. paste the password into say an xterm with *different* foreground and
  572. background colours.  This immediately shows the password.
  573.  
  574. -----------------------------------------------------------------------------
  575. Subject: 35) How can I replace characters typed with say a `*'?  I want to
  576. replace input for password entry.
  577.  
  578. Answer: In Motif 1.1 Use the modifyVerifyCallback to tell when input is
  579. received.  Set text->ptr in the callback structure to '*'. This does not work
  580. under 1.0 because of an oversight in which changes to this are ignored.  In
  581. Motif 1.0, what you can do is set the doit flag to 'false' so the text is not
  582. displayed. Then set a static boolean to True to prevent re-entrance.  Next
  583. call XmTextReplace() to display your '*'.  then reset your re-entrance flag to
  584. False.  XmTextReplace() will call the XmNmodifyVerify callback.  To prevent
  585. getting into an infinite loop, you need the re-entrance flag.
  586.  
  587. The following program from Dan Heller illustrates this:
  588. --------------
  589. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  590.  * This program is freely distributable without licensing fees and
  591.  * is provided without guarantee or warranty expressed or implied.
  592.  * This program is -not- in the public domain.  This program appears
  593.  * in the Motif Programming Manual, O'Reilly Volume 6.
  594.  */
  595.  
  596. /* passwd.c -- prompt for a passwd.  Meaning, all input looks like
  597.  * a series of *'s.  Store the actual data typed by the user in
  598.  * an internal variable.  Don't allow paste operations.  Handle
  599.  * backspacing by deleting all text from insertion point to the
  600.  * end of text.
  601.  */
  602. #include <Xm/Text.h>
  603. #include <Xm/LabelG.h>
  604. #include <Xm/RowColumn.h>
  605. #include <ctype.h>
  606.  
  607. void check_passwd();
  608. char *passwd; /* store user-typed passwd here. */
  609.  
  610. main(argc, argv)
  611. int argc;
  612. char *argv[];
  613. {
  614.     Widget        toplevel, text_w, rowcol;
  615.     XtAppContext  app;
  616.  
  617.     toplevel = XtVaAppInitialize(&app, "Demos",
  618.         NULL, 0, &argc, argv, NULL, NULL);
  619.  
  620.     rowcol = XtVaCreateWidget("rowcol",
  621.         xmRowColumnWidgetClass, toplevel,
  622.         XmNorientation, XmHORIZONTAL,
  623.         NULL);
  624.  
  625.     XtVaCreateManagedWidget("Password:",
  626.         xmLabelGadgetClass, rowcol, NULL);
  627.     text_w = XtVaCreateManagedWidget("text_w",
  628.         xmTextWidgetClass, rowcol, NULL);
  629.  
  630.     XtAddCallback(text_w, XmNmodifyVerifyCallback, check_passwd, NULL);
  631.     XtAddCallback(text_w, XmNactivateCallback, check_passwd, NULL);
  632.  
  633.     XtManageChild(rowcol);
  634.     XtRealizeWidget(toplevel);
  635.     XtAppMainLoop(app);
  636. }
  637.  
  638. void
  639. check_passwd(text_w, unused, cbs)
  640. Widget        text_w;
  641. XtPointer     unused;
  642. XmTextVerifyCallbackStruct *cbs;
  643. {
  644.     char *new;
  645.     int len;
  646.  
  647.     if (cbs->reason == XmCR_ACTIVATE) {
  648.         printf("Password: %s\n", passwd);
  649.         return;
  650.     }
  651.  
  652.     if (cbs->text->ptr == NULL) { /* backspace */
  653.         cbs->endPos = strlen(passwd); /* delete from here to end */
  654.         passwd[cbs->startPos] = 0; /* backspace--terminate */
  655.         return;
  656.     }
  657.  
  658.     if (cbs->text->length > 1) {
  659.         cbs->doit = False; /* don't allow "paste" operations */
  660.         return; /* make the user *type* the password! */
  661.     }
  662.  
  663.     new = XtMalloc(cbs->endPos + 2); /* new char + NULL terminator */
  664.     if (passwd) {
  665.         strcpy(new, passwd);
  666.         XtFree(passwd);
  667.     } else
  668.         new[0] = NULL;
  669.     passwd = new;
  670.     strncat(passwd, cbs->text->ptr, cbs->text->length);
  671.     passwd[cbs->endPos + cbs->text->length] = 0;
  672.  
  673.     for (len = 0; len < cbs->text->length; len++)
  674.         cbs->text->ptr[len] = '*';
  675. }
  676.  
  677.  
  678. -----------------------------------------------------------------------------
  679. Subject: 36) How can I best add a large piece of text to a scrolled text
  680. widget?  In some versions of Motif 1.0 even using XmTextSetString, it insists
  681. on adding the text one line at a time, adjusting the scroll bar each time. It
  682. looks awful and is slow.
  683.  
  684. Answer: If you don't have this problem, use XmTextSetString to set all of the
  685. text in the widget.  If you do have this slowdown problem even using
  686. XmTextSetString, unmanage the widget, add the text and then manage it again.
  687. This may cause the window to blink, but you have to put up with that or switch
  688. to a different version of Motif.
  689.  
  690. -----------------------------------------------------------------------------
  691. Subject: 37) How can I highlight text in the Text widget?
  692.  
  693. Answer: From: argv@zipcode.com (Dan Heller)
  694.  
  695. If you don't need font or color changes, you can do all this using a Text
  696. widget very easily [in Motif 1.1, anyway].
  697.  
  698.         loop() {
  699.             pos = offset_of_pattern_in_text_widget(pattern, text_w);
  700.             search_len = strlen(pattern);
  701.             XmTextSetHighlight(text_w, pos, pos+search_len,
  702.                         XmHIGHLIGHT_SELECTED);
  703.         }
  704.  
  705.  
  706. There are two choices for highlighting: reverse video (HIGHLIGHT_SELECTED) and
  707. underlined (HIGHLIGHT_SECONDARY_SELECTED).  Be careful that your users won't
  708. confuse your highlights with actual selections!
  709.  
  710. -----------------------------------------------------------------------------
  711. Subject: 38)  How can I select all of the text in a widget programmatically?
  712. So that some initial text is displayed, but anything typed replaces it.
  713.  
  714. Answer: XmTextSetSelection(Text1, 0, XmTextGetLastPosition(Text1), event-
  715. >xbutton.time);
  716.  
  717. where Text1 is the widget in question (obviously) and event is some event that
  718. triggered this call.  You can use XtLastTimestampProcessed( display) instead
  719. of xbutton.time if you don't happen to have an event pointer handy.
  720.  
  721.  
  722.  
  723.  
  724. -----------------------------------------------------------------------------
  725. Subject: 39) How can I change colours of text in the Text widget?  I want some
  726. of the text in one colour, some in another.
  727.